package com.ytf.test.fifth;

/**
 * @author: YTF
 * @date: 2024/9/18 11:40
 * @version: 1.0
 * @description:
 */
public class Tree {
    int height;
    public Tree() {
        System.out.println("Planting a seedLing");
        height=0;
    }

    public Tree(int height) {
        this.height = height;
        System.out.println("Creating new Tree that is"+height+" feet tall");
    }

    void info(){
        System.out.println("Tree is "+height+" feet tall");
    }
    void info(String s){
        System.out.println(s+"Tree is "+height+" feet tall");
    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            Tree tree =new Tree(i);
            tree.info();
            tree.info("overLoaded method");
        }
        // Overloaded constructor:
        new Tree();
        /**
         * Output:
         * Creating new Tree that is0 feet tall
         * Tree is 0 feet tall
         * overLoaded methodTree is 0 feet tall
         * Creating new Tree that is1 feet tall
         * Tree is 1 feet tall
         * overLoaded methodTree is 1 feet tall
         * Creating new Tree that is2 feet tall
         * Tree is 2 feet tall
         * overLoaded methodTree is 2 feet tall
         * Creating new Tree that is3 feet tall
         * Tree is 3 feet tall
         * overLoaded methodTree is 3 feet tall
         * Creating new Tree that is4 feet tall
         * Tree is 4 feet tall
         * overLoaded methodTree is 4 feet tall
         * Planting a seedLing
         *
         */
    }
}
